package com.security.dataprocess.service.impl;

import com.baomidou.dynamic.datasource.annotation.DS;
import com.baomidou.mybatisplus.core.metadata.IPage;
import com.baomidou.mybatisplus.core.toolkit.Wrappers;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;
import com.security.dataprocess.mapper.EnterpriseInfoMapper;
import com.security.dataprocess.model.EnterpriseInfo;
import com.security.dataprocess.service.IEnterpriseInfoService;
import org.springframework.stereotype.Service;

/**
 * <p>
 * 企业信息表 服务实现类
 * </p>
 *
 * @author H
 * @since 2022-12-19
 */
@Service
@DS("mysql2") //指定数据源
public class EnterpriseInfoServiceImpl extends ServiceImpl<EnterpriseInfoMapper, EnterpriseInfo> implements IEnterpriseInfoService {

    @Override
    public  IPage<EnterpriseInfo> findListByPage(Integer page, Integer pageCount){
        IPage<EnterpriseInfo> wherePage = new Page<>(page, pageCount);
        EnterpriseInfo where = new EnterpriseInfo();

        return   baseMapper.selectPage(wherePage, Wrappers.query(where));
    }

    @Override
    public int add(EnterpriseInfo enterpriseInfo){
        return baseMapper.insert(enterpriseInfo);
    }

    @Override
    public int delete(Long id){
        return baseMapper.deleteById(id);
    }

    @Override
    public int updateData(EnterpriseInfo enterpriseInfo){
        return baseMapper.updateById(enterpriseInfo);
    }

    @Override
    public EnterpriseInfo findById(Long id){
        return  baseMapper.selectById(id);
    }
}
